<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>组件基础</title>
</head>

<body>
    <div id="app">
        <blog-post title="My journey with Vue"></blog-post>
        <blog-post title="Blogging with Vue"></blog-post>
        <blog-post title="Why Vue is so fun"></blog-post>

        <hr>
        <blog-post v-for="post in posts" v-bind:key="post.id" v-bind:title="post.title"></blog-post>
    </div>

    <script type="module">
        import Vue from '../vue.esm.browser.js'

        // Vue.component('blog-post', {
        //     props: ['title'],
        //     template: '<h3>{{ title }}</h3>'
        // })

        Vue.component('blog-post', {
            props: ['title'],
            template: `
                <div class="blog-post">
                    <h3>{{ title }}</h3>
                    <div v-html="content"></div>
                </div>
            `
        })

        const app = new Vue({
            el: '#app',
            data: {
                posts: [
                    { id: 1, title: 'My journey with Vue' },
                    { id: 2, title: 'Blogging with Vue' },
                    { id: 3, title: 'Why Vue is so fun' }
                ]
            },
        })
    </script>
</body>

</html>